package com.zz.io;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;

public class Test2 {
    public static void main(String args[]) throws IOException {
        //1.建立输入流和文件的管道
        FileInputStream fileInputStream = new FileInputStream("opp-app1\\src\\data\\test1.txt");
        //2.获取文件大小
        File file = new File("opp-app1\\src\\data\\test1.txt");
        //4.创建一个文件大小的字节数组buffer
        long size = file.length();
        byte[] buffer = new byte[(int)size];//适合读取小文件
        //将文件内容装入buffer中，返回int
        int s = fileInputStream.read(buffer);
        System.out.println(new String(buffer));
    }
}
